package com.jyu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jyu.dao.ManagerDao;
import com.jyu.domain.Manager;
import com.jyu.utils.R;
import com.jyu.service.ManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;

@Service
public class ManagerServiceImpl extends ServiceImpl<ManagerDao, Manager> implements ManagerService {

    @Autowired
    private ManagerDao managerDao;

    @Override
    public R login(HttpServletRequest request, String name, String password) {
        Manager manager = managerDao.selectOne(new QueryWrapper<Manager>().eq("name", name)
                .eq("password", password));
        if (manager != null) {

            request.getSession().setAttribute("manager",manager);

            return new R(true,manager);
        } else {
            return new R(false,manager);
        }
    }
}

